﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TextEditApp.Algorithm;

namespace TextEditApp.Forms
{
    public partial class SingleCountForm : Form
    {
        public SingleCountForm()
        {
            InitializeComponent();
        }

        private void btn_count_Click(object sender, EventArgs e)
        {
            Main mainForm = (Main)this.Owner;
            string text = mainForm.tbx_main.Text;
            string[] ary = Util.GetWordArray(text);
            lbl_result.Text = $"{tbx_find.Text}:{ary.Count(t => t == tbx_find.Text)}";
        }

        private void lbl_result_Click(object sender, EventArgs e)
        {

        }

        private void SingleCountForm_Load(object sender, EventArgs e)
        {
            AnotherDictionary d = AnotherDictionary.GetDictionary;
            tbx_find.AutoCompleteCustomSource.AddRange(d.GetWords());
            tbx_find.AutoCompleteMode = AutoCompleteMode.Suggest;
            tbx_find.AutoCompleteSource = AutoCompleteSource.CustomSource;
        }
    }
}
